/**
 * 
 */
package com.zznode.redsun.smartcrm.model;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import com.zznode.csp.domain.basemodel.DomainValue;
import com.zznode.csp.domain.basemodel.UnDeletable;

/**
 * 消费记录
 * 
 * @author taoping
 * 
 */
@Entity
@Table(name = "b_consume_record")
@DynamicInsert
@DynamicUpdate
public class ConsumeRecord extends DomainValue implements UnDeletable {

	private static final long serialVersionUID = 1L;

	@Column(name = "is_deleted")
	private Boolean isDeleted = Boolean.FALSE;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "customer_id")
	private Customer customer;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "product_id")
	private Product product;

	@Column(name = "quantity")
	private Long quantity;

	@Column(name = "amount")
	private BigDecimal amount;

	@Column(name = "create_date")
	private Date createTime;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "create_user")
	private PersonalInfo createUser;

	@Column(name = "description")
	private String description;

	@Override
	public boolean isDeleted() {
		return null == this.isDeleted ? false : this.isDeleted.booleanValue();
	}

	@Override
	public void markedAsAvailable() {
		this.isDeleted = Boolean.FALSE;
	}

	@Override
	public void markedAsDeleted() {
		this.isDeleted = Boolean.TRUE;
	}

	public Boolean getIsDeleted() {
		return isDeleted;
	}

	public void setIsDeleted(Boolean isDeleted) {
		this.isDeleted = isDeleted;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Long getQuantity() {
		return quantity;
	}

	public void setQuantity(Long quantity) {
		this.quantity = quantity;
	}

	public BigDecimal getAmount() {
		return amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public PersonalInfo getCreateUser() {
		return createUser;
	}

	public void setCreateUser(PersonalInfo createUser) {
		this.createUser = createUser;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
}
